<!--待公证-->
<template>
  <div>
    <el-form :model="checkForm" label-width="100px" class="demo-ruleForm" ref="checkForm">
      <el-form-item label="办理结果" prop="approveStatus"  :rules="[{ required: true, message: '请选择办理结果', trigger: 'change' }]">
        <el-radio-group v-model="checkForm.approveStatus" @change="handleChange">
          <el-radio label="7" class="red">转派</el-radio>
          <el-radio label="3" class="red">退件</el-radio>
          <el-radio label="5" class="red">拒件</el-radio>
          <el-radio label="9" class="red">通过</el-radio>
        </el-radio-group>
      </el-form-item>

      <el-form-item label="转派" prop="checkerId" v-if="checkForm.approveStatus === '7'" required>
        <el-select v-model="checkForm.checkerId" placeholder="请选择">
          <el-option v-for="item in sendCheckPersons" :key="item.id" :label="item.nameAndMobile" :value="item.id"> </el-option>
        </el-select>
      </el-form-item>
      
      <el-form-item label="签约公证完成时间" prop="approvalDTO.signNotaryCompleteTime" v-if="checkForm.approveStatus == 9" label-width="150px"  
        :rules="[{ required: true, message: '公证完成时间不能为空', trigger: 'change' }]">
          <el-date-picker :picker-options="pickerOption" v-model="checkForm.approvalDTO.signNotaryCompleteTime" type="datetime" placeholder="选择日期" style="width: 300px" value-format="yyyy-MM-dd HH:mm:ss"> </el-date-picker>
      </el-form-item>

      <el-form-item label="反馈信息" prop="opinion">
        <el-input type="textarea" :rows="7" v-model="checkForm.opinion" style="width: 300px"></el-input>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="submitForm('checkForm')" v-loading="loading">提交</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import { notaryCheck, listRedePloyUser } from '@/api/project';
export default {
  props: {
    projectId: undefined,
    taskId: undefined,
  },
  data() {
    return {
      pickerOption: {
        disabledDate(current) {
          return current && current.getTime() > new Date().getTime();
        },
      },
      checkForm: {
        approveStatus: undefined,
        checkerId: undefined,
        opinion: undefined,
        approvalDTO:{
          signNotaryCompleteTime:undefined
        }
      },
      loading: false
    };
  },
  created() {
    // 初始化数据
    this.listRedePloyUser();
  },
  methods: {
    submitForm(checkForm) {
      this.$refs[checkForm].validate((valid) => {
          if (valid) {
            this.checkForm.projectId = this.projectId,
            this.checkForm.taskId = this.taskId,
            this.checkForm.approvalDTO.projectId = this.projectId
            this.$confirm('你确定要提交吗?', '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning',
            }).then(() => {
              // 开始提交信息
              this.loading = true;
              notaryCheck(this.checkForm).then((data) => {
                this.loading = false;
                  this.$notify.success({
                    title: '成功',
                    message: '操作成功'
                  })
                this.$store.dispatch("tagsView/delView", this.$route);
                this.$router.go(-1);
              }).catch(() => {
                this.loading = false;
              })
            });
        }
      })
    },
    listRedePloyUser() {
      // 查询数据 构造页面
      listRedePloyUser('办押岗').then((data) => {
        this.sendCheckPersons = data.data;
        console.log('响应数据:%o', data);
      });
    },
    //节点判断
    handleChange(val) {
      this.restForm();
      this.checkForm.approveStatus = val;
      this.checkerId = false;
      // 补资料
      if (val === '7') {
        this.checkerId = true;
      }
      return;
    },
    restForm() {
      this.checkForm = {
        opinion: undefined,
        checkerId: undefined,
        approveStatus: undefined,
        approvalDTO:{
          signNotaryCompleteTime:undefined
        }

      };
    },
  },
};
</script>
